<template>
    <div class="product-container">
      <ul>
        <li v-for="item in goodsList" :key="item.id" @click="toProductsDetail(item.id)">
          <van-image fit="cover" :src="item.list_pic_url"></van-image>
          <div class="tmain">
            <div class="van-ellipsis">{{item.name}}</div>
            <div class="price">{{item.retail_price | RMBformat}}</div>
          </div>
        </li>
      </ul>
    </div>
  </template>
  
  <script>
  export default {
    name: 'SearchResults',
    data () {
      return {}
    },
    props: [
      'goodsList'
    ],
    methods: {
      toProductsDetail (id) {
        this.$router.push('/productsDetail?id=' + id)
        // 点击页面刷新，延迟
        setTimeout(() => {
          this.$router.go(0)
        }, 10)
      }
    }
  }
  </script>
  
  <style lang="less" scoped>
  .product-container{
    padding: 10px;
    height: calc(100vh - 102px);
    overflow-y: auto;
    ul{
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      padding-bottom: 15px;
      li{
        width: 172px;
        margin-bottom: 10px;
        background-color: #fff;
        border-radius: 10px;
        text-align: center;
        overflow: hidden;
        .van-image{
          width: 100%;
          height: 150px;
        }
        .tmain{
          padding: 10px;
        }
        .van-ellipsis{
          font-size: 16px;
          color: #333;
        }
        .price{
          font-size: 14px;
          color: #f00;
          margin-top: 8px;
        }
      }
    }
  }
  </style>
  